Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kbn-grid-layout] Store rows in object instead of array #212965

Merged

Conversation

Heenawter
Copy link
Contributor

@Heenawter Heenawter commented Mar 3, 2025

Closes #211930

Summary

This PR makes it so that kbn-grid-layout stores its rows as an object / dictionary ({ [key: string]: GridRowData }) rather than an array (Array<GridRowData>). This is a prerequisite for #190381 , since it allows us to re-order rows without re-rendering their contents. It also means that deleting a row will no longer cause the rows below it to re-render, since re-rendering is now dependant on the row's ID rather than the row's order.

Before

Screen.Recording.2025-03-03.at.2.56.19.PM.mov

After

Screen.Recording.2025-03-03.at.2.51.58.PM.mov

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

@Heenawter Heenawter added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:small Small Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Project:Collapsable Panels Related to the project for adding collapsable sections to Dashboards. backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Mar 3, 2025
@Heenawter Heenawter self-assigned this Mar 3, 2025
@Heenawter Heenawter force-pushed the kbn-grid-layout_switch-to-row-key_2025-03-03 branch from f3db5d9 to daea05f Compare March 3, 2025 21:51
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/grid-layout 16 19 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 543.3KB 543.5KB +172.0B
Unknown metric groups

API count

id before after diff
@kbn/grid-layout 17 20 +3

History

cc @Heenawter

@Heenawter Heenawter marked this pull request as ready for review March 4, 2025 00:43
@Heenawter Heenawter requested a review from a team as a code owner March 4, 2025 00:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@ThomThomson ThomThomson self-requested a review March 4, 2025 19:57
Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are very straightforward and LGTM!

Read through the code and tested locally in the grid example app. Great change!

@Heenawter Heenawter merged commit b32f0fe into elastic:main Mar 4, 2025
9 checks passed
@Heenawter Heenawter deleted the kbn-grid-layout_switch-to-row-key_2025-03-03 branch March 4, 2025 20:34
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/13662442571

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 4, 2025
Closes elastic#211930

## Summary

This PR makes it so that `kbn-grid-layout` stores its rows as an object
/ dictionary (`{ [key: string]: GridRowData }`) rather than an array
(`Array<GridRowData>`). This is a prerequisite for
elastic#190381 , since it allows us to
re-order rows without re-rendering their contents. It also means that
deleting a row will no longer cause the rows below it to re-render,
since re-rendering is now dependant on the row's **ID** rather than the
row's order.

**Before**

https://github.com/user-attachments/assets/83651b24-a32c-4953-8ad5-c0eced163eb5

**After**

https://github.com/user-attachments/assets/9cef6dbc-3d62-46aa-bc40-ab24fc4e5556

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit b32f0fe)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Mar 4, 2025
… (#213162)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[kbn-grid-layout] Store rows in object instead of array
(#212965)](#212965)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Hannah
Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-04T20:34:39Z","message":"[kbn-grid-layout]
Store rows in object instead of array (#212965)\n\nCloses
https://github.com/elastic/kibana/issues/211930\n\n## Summary\n\nThis PR
makes it so that `kbn-grid-layout` stores its rows as an object\n/
dictionary (`{ [key: string]: GridRowData }`) rather than an
array\n(`Array<GridRowData>`). This is a prerequisite
for\nhttps://github.com//issues/190381 , since it allows
us to\nre-order rows without re-rendering their contents. It also means
that\ndeleting a row will no longer cause the rows below it to
re-render,\nsince re-rendering is now dependant on the row's **ID**
rather than the\nrow's
order.\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/83651b24-a32c-4953-8ad5-c0eced163eb5\n\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/9cef6dbc-3d62-46aa-bc40-ab24fc4e5556\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"b32f0fe1e863a599c9d61a38e99c974deec6519a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","loe:small","release_note:skip","impact:high","Project:Collapsable
Panels","backport:version","v9.1.0","v8.19.0"],"title":"[kbn-grid-layout]
Store rows in object instead of
array","number":212965,"url":"https://github.com/elastic/kibana/pull/212965","mergeCommit":{"message":"[kbn-grid-layout]
Store rows in object instead of array (#212965)\n\nCloses
https://github.com/elastic/kibana/issues/211930\n\n## Summary\n\nThis PR
makes it so that `kbn-grid-layout` stores its rows as an object\n/
dictionary (`{ [key: string]: GridRowData }`) rather than an
array\n(`Array<GridRowData>`). This is a prerequisite
for\nhttps://github.com//issues/190381 , since it allows
us to\nre-order rows without re-rendering their contents. It also means
that\ndeleting a row will no longer cause the rows below it to
re-render,\nsince re-rendering is now dependant on the row's **ID**
rather than the\nrow's
order.\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/83651b24-a32c-4953-8ad5-c0eced163eb5\n\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/9cef6dbc-3d62-46aa-bc40-ab24fc4e5556\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"b32f0fe1e863a599c9d61a38e99c974deec6519a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212965","number":212965,"mergeCommit":{"message":"[kbn-grid-layout]
Store rows in object instead of array (#212965)\n\nCloses
https://github.com/elastic/kibana/issues/211930\n\n## Summary\n\nThis PR
makes it so that `kbn-grid-layout` stores its rows as an object\n/
dictionary (`{ [key: string]: GridRowData }`) rather than an
array\n(`Array<GridRowData>`). This is a prerequisite
for\nhttps://github.com//issues/190381 , since it allows
us to\nre-order rows without re-rendering their contents. It also means
that\ndeleting a row will no longer cause the rows below it to
re-render,\nsince re-rendering is now dependant on the row's **ID**
rather than the\nrow's
order.\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/83651b24-a32c-4953-8ad5-c0eced163eb5\n\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/9cef6dbc-3d62-46aa-bc40-ab24fc4e5556\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"b32f0fe1e863a599c9d61a38e99c974deec6519a"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:small Small Level of Effort Project:Collapsable Panels Related to the project for adding collapsable sections to Dashboards. release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[kbn-grid-layout] [Collapsable Panels] Store rows as dictionary
4 participants